﻿//using System.Transactions;
using System;
using System.Collections;
using Unis.Framework.ORM.BaseDefiniens.Enums;
using Unis.Framework.ORM.Model;
using Unis.ORM.IFace;

namespace Unis.Framework.ORM.IFace
{
    public interface IPersistenceManager : IDisposable
    {
        // Methods
        void Attach(object entity);
        void Attach(object entity, PersistOptions options);
        void Cancel();
        void Close();
        void Delete(object entity);
        void Delete(object entity, PersistOptions options);
        void Evict(object entity);
        void EvictAll();
        void EvictAll(object[] pcs);
        void EvictAll(IEnumerable pcs);
        T FindByPrimaryKey<T>(params object[] id);
        T FindByPrimaryKey<T>(PersistOptions options, params object[] id);
        object FindByPrimaryKey(Type entityType, params object[] id);
        object FindByPrimaryKey(Type entityType, PersistOptions options, params object[] id);
        bool Flush();
        ICollection GetManagedEntities();
        EntityState GetState(object entity);
        IQuery<T> NewQuery<T>();
        IQuery NewQuery();
        IQuery<T> NewQuery<T>(string filter);
        IQuery NewQuery(Type entityType);
        IQuery NewQuery(Type entityType, string filter);
        void Persist(object entity);
        void Persist(object entity, PersistOptions options);
        void Persist(object entity, params string[] properties);
        void Persist(object entity, PersistOptions options, params string[] properties);
        void PersistNew(object entity);
        void PersistNew(object entity, params string[] properties);
        void PersistNew(object entity, PersistOptions options);
        void PersistNew(object entity, PersistOptions options, params string[] properties);
        void Reload(ref object entity);
        void Reload(ref object entity, PersistOptions options);
        void Update(object entity);
        void Update(object entity, params string[] properties);
        void Update(object entity, PersistOptions options);
        void Update(object entity, PersistOptions options, params string[] properties);

        // Properties
        ITransaction CurrentTransaction { get; }
        bool IgnoreCache { get; set; }
        bool IsClosed { get; }
    }
}
